package cn.darkhorse.alarm.service.alarm;

import cn.darkhorse.alarm.pojo.AlarmParameterSettings;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;


/**
 * @author yuanjun
 * @since 2023/4/7 10:03
 */
@Component
public class AlarmManager implements Alarm {

    @Resource
    private SwitchAlarm switchAlarm;
    @Resource
    private CharacterAlarm characterAlarm;
    @Resource
    private EnumerationAlarm enumerationAlarm;

    @Resource
    private LimitValueAlarm limitValueAlarm;

    @Resource
    private ContinuousAlarm continuousAlarm;

    @Override
    public void doAlarm(AlarmParameterSettings settings, Map<String,Object> data) {
        if(null == settings) {
            return;
        }

        if(null == settings.getAlarm() || !settings.getAlarm()) {
            return;
        }

        //开关类型
        switchAlarm.doAlarm(settings, data);
        characterAlarm.doAlarm(settings, data);
        enumerationAlarm.doAlarm(settings, data);
        limitValueAlarm.doAlarm(settings, data);
        continuousAlarm.doAlarm(settings, data);
    }
}
